package org.example.config;

import org.example.constant.Constants;
import org.springframework.amqp.core.*;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitmqConfig {
    @Bean("userQueue")
    public Queue userQueue() {
        return QueueBuilder.durable(Constants.USER_QUEUE_NAME).build();
    }
    @Bean("userExchange")
    public FanoutExchange userExchange() {
        return ExchangeBuilder.fanoutExchange(Constants.USER_EXCHANGE_NAME).build();
    }
    @Bean("userBind")
    public Binding userBind(@Qualifier("userExchange") FanoutExchange userExchange, @Qualifier("userQueue") Queue userQueue) {
        return BindingBuilder.bind(userQueue).to(userExchange);
    }
}
